package dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;

import vo.CommunityVo;

public class CommunityDao {
	
	static CommunityDao me;
	
	
	public CommunityDao(){
		me=this;
	}
	public static CommunityDao getDao() {
		return me;
	}
	
	///////////////////////////////////////////////

	SqlSessionTemplate sqlSession;

	public SqlSessionTemplate getSqlSession() {
		return sqlSession;
	}

	public void setSqlSession(SqlSessionTemplate sqlSession) {
		this.sqlSession = sqlSession;
	}
	
	//////////////////////////////////////////////////////
	
	public List<CommunityVo> selectCommunityBoardAll(CommunityVo cvo){
		List<CommunityVo> list = sqlSession.selectList("select_community_board_list",cvo);
		return list;
	}
	
	public List<CommunityVo> communityCategoryList(int menu_no){
		List<CommunityVo> list = sqlSession.selectList("select_community_category", menu_no);
		return list;
	}
	
	public CommunityVo selectCommnunityBoardOne(int b_no){
		CommunityVo cvo = sqlSession.selectOne("select_community_board_one", b_no);
		return cvo;
	}
	public void insertCommunityBoard(CommunityVo cvo){
		sqlSession.insert("insert_community_board", cvo);
	}
	
	public String selectCheckPwd(int b_no){
		String pwd = sqlSession.selectOne("select_check_pwd", b_no);
		return pwd;
	}
	public void deleteCommunityBoard(int b_no){
		sqlSession.delete("delete_community_board",b_no);
	}
	public void modifyCommunityBoard(CommunityVo cvo){
		sqlSession.update("update_community_board", cvo);
	}
	public List<CommunityVo> selectReplyList(int b_no){
		List<CommunityVo> list = sqlSession.selectList("select_reply_list", b_no);
		return list;
	}
	public void replyWrite(CommunityVo cvo){
		sqlSession.insert("insert_community_reply", cvo);
	}
	public int selectReplyCount(int b_no){
		int count = sqlSession.selectOne("select_reply_count", b_no);
		return count;
	}
	public void updateReplyCount(Map<String,Integer> map){
		sqlSession.update("update_reply_count", map);
	}
	public void modifyReplyContent(CommunityVo cvo){
		sqlSession.update("modify_board_reply", cvo);
	}
	public void deleteReply(int b_no){
		sqlSession.delete("delete_reply", b_no);
	}
	
	public void boardNotice(CommunityVo cvo)
	{
		sqlSession.insert("insert_notice_board", cvo);
	}
	public List<CommunityVo> selectNoticeList(){
		List<CommunityVo> list = sqlSession.selectList("select_notice_list");
		return list;
	}
	public void updateNotice(){
		sqlSession.update("update_notice");
	}
	public void noticeUpdate(){
		sqlSession.update("notice_update");
	}
	public int getRowCount(CommunityVo vo){
		int count = 
		sqlSession.selectOne("board_count" ,vo);
		return count;
	}
	public List<CommunityVo> selectRange(CommunityVo vo){
		List<CommunityVo> list = 
		sqlSession.selectList("board_select_range", vo);
		return list;
	}
	public int getConditionRowCount(CommunityVo vo){
		int count = 
		sqlSession.selectOne("board_count_condition", vo);
		return count;
	}
	public List<CommunityVo> selectRangeCondition(CommunityVo vo){
		List<CommunityVo> list =
		sqlSession.selectList("select_range_condition", vo);
		return list;
	}
	public List<CommunityVo> selectBoardListAll(CommunityVo vo){
		List<CommunityVo> list =
		sqlSession.selectList("select_community_board_list_all", vo);
		return list;
	}
	public int getRowCountAll(CommunityVo vo){
		int count = 
		sqlSession.selectOne("board_count_all", vo);
		return count;
	}
	public int getConditionRowConutAll(CommunityVo vo){
		int count =
		sqlSession.selectOne("board_count_condition_all", vo);
		return count;
	}
	public List<CommunityVo> selectRangeConditionAll(CommunityVo vo){
		List<CommunityVo> list =
		sqlSession.selectList("select_range_condition_all", vo);
		return list;
	}
	
	
	
	public List<CommunityVo> selectLocalBoardList(){
		List<CommunityVo> list =
		sqlSession.selectList("select_local_board_list");
		return list;
	}
	
	
	public List<CommunityVo> selectNoticeListAll(CommunityVo vo){
		List<CommunityVo> list =
		sqlSession.selectList("select_community_notice_list_all", vo);
		return list;
	}
	public int getNoticeRowCountAll(CommunityVo vo){
		int count = 
		sqlSession.selectOne("notice_count_all", vo);
		return count;
	}
	public void updateReadhit(int b_no){
		sqlSession.update("board_update_readhit", b_no);
	}
	
	
	
	/*public int getConditionRowCountNotice(CommunityVo vo){
		int count = 
		sqlSession.selectOne("board_count_condition_notice", vo);
		return count;
	}
	public List<CommunityVo> selectRangeConditionNotice(CommunityVo vo){
		List<CommunityVo> list=
		sqlSession.selectList("select_range_condition_notice", vo);
		return list;
	}*/
	
}
